select CUSTOMER.ZCODE,CUSTOMER.NAME1,CUSTOMER.WERKS,formmain_0182.field0001 as DQBS,formmain_0176.ID from CUSTOMER
left outer join formmain_0176 on trim(CUSTOMER.ZCODE)=trim(formmain_0176.field0001) and trim(CUSTOMER.WERKS)=trim(formmain_0176.FIELD0003)
left outer join formmain_0182 on CUSTOMER.WERKS=formmain_0182.field0002
where formmain_0176.ID is null